package Memento;

import Debog.Debog;


public class Memoire extends Debog {

        private PileDeMemento undostack;
        private PileDeMemento redostack;
        
        public Memoire() {
                undostack=new PileDeMemento();
                redostack=new PileDeMemento();
        }
        public void add (Memento m){
                undostack.push(m);
                redostack.clear();
        }
        public void annuler(){
                if(!undostack.isEmpty())
                {
                        Memento m=undostack.pop();
                        debog("Unexecute "+m.toString());
                        m.unexecute();
                        redostack.push(m);
                }
        }
        public void refaire(){
                if(!redostack.isEmpty())
                {
                        Memento m=redostack.pop();
                        debog("Execute "+m.toString());
                        m.execute();
                        undostack.push(m);
                }
        }
        
}